package com.itboye.textileexpes.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpes.beans.ForresterBeans;
import com.itboye.textileexpes.beans.RootBean;
import com.itboye.textileexpes.interfaces.IAppUpdate;
import com.itboye.textileexpes.interfaces.ICategory;
import com.itboye.textileexpes.interfaces.IGetYanZhengMa;
import com.itboye.textileexpes.repository.APPUpdateRepository;
import com.itboye.textileexpes.repository.CategoryRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

public class CategoryPresenter extends BasePresenter implements
		ICategory<ForresterBeans> {
	// 查询一级类目
	public static final String category_success = MainPresenter.class.getName()
			+ "_category_success";
	public static final String category_fail = MainPresenter.class.getName()
			+ "_category_fail";
	// 收藏类目
	public static final String collection_success = MainPresenter.class
			.getName() + "_collection_success";
	public static final String collection_fail = MainPresenter.class.getName()
			+ "_collection_fail";

	// 分頁
	public static final String collectioncategory_success = MainPresenter.class
			.getName() + "_collectioncategory_success";
	public static final String collectioncategory_fail = MainPresenter.class
			.getName() + "_collectioncategory_fail";

	// 购物车
	public static final String ShopChar_success = MainPresenter.class.getName()
			+ "_ShopChar_success";
	public static final String ShopChar_fail = MainPresenter.class.getName()
			+ "_ShopChar_fail";

	// 购物车
	public static final String Photo_success = MainPresenter.class.getName()
			+ "_Photo_success";
	public static final String Photo_fail = MainPresenter.class.getName()
			+ "_Photo_fail";

	public CategoryPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ForresterBeans model) {
		// TODO Auto-generated method stub
		ICategory<ForresterBeans> addGoods = new CategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(category_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(category_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		addGoods.getInfo(model);
	}

	@Override
	public List<ForresterBeans> query(ForresterBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onColletion(String uid) {
		// TODO Auto-generated method stub
		ICategory<ForresterBeans> addGoods = new CategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collection_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collection_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		addGoods.onColletion(uid);
	}

	@Override
	public void onColletionCate(String id, String uid) {
		// TODO Auto-generated method stub
		ICategory<ForresterBeans> addGoods = new CategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collectioncategory_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collectioncategory_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		addGoods.onColletionCate(id, uid);
	}

	@Override
	public void onShopcar(String uid) {
		// TODO Auto-generated method stub
		ICategory<ForresterBeans> addGoods = new CategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopChar_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopChar_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		addGoods.onShopcar(uid);
	}

	@Override
	public void onPhoto(String img_ids, String uid, String desc,
			String contact_addr) {
		// TODO Auto-generated method stub
		ICategory<ForresterBeans> addGoods = new CategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Photo_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Photo_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		addGoods.onPhoto(img_ids, uid, desc, contact_addr);
	}

}
